package com.jingdianjichi.subject.application.controller;

import com.alibaba.fastjson.JSON;
import com.jingdianjichi.subject.common.entity.PageResult;
import com.jingdianjichi.subject.infra.basic.entity.SubjectInfoEs;
import com.jingdianjichi.subject.infra.basic.service.SubjectEsService;
import com.jingdianjichi.subject.infra.entity.UserInfo;
import com.jingdianjichi.subject.infra.rpc.UserRpc;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Description:
 *
 * @Author dal
 * @Create 2024/6/1 0:27
 */
@RestController
@RequestMapping("/Feign")
@Slf4j
public class TestFeignController {
    @Resource
    private UserRpc userRpc;
    @Resource
    private SubjectEsService subjectEsService;

    @GetMapping("testFeign")
    public void testFeign() {
        UserInfo userInfo = userRpc.getUserInfo("obhUJ6cN3tMcY8zb0_6p_F4sr28M");
        log.info("userInfo:{}", userInfo);
    }
    @PostMapping("")
    public void querySubjectByKeyword(){
        SubjectInfoEs subjectInfoEs = new SubjectInfoEs();
        subjectInfoEs.setKeyWord("redis");
        PageResult<SubjectInfoEs> pageResult = subjectEsService.querySubjectList(subjectInfoEs);
        log.info("querySubjectByKeyword:{}", JSON.toJSONString(pageResult));
    }

//    @GetMapping("/testCreateIndex")
//    public void testCreateIndex() {
//        subjectEsService.createIndex();
//    }
//
//    @GetMapping("/addDocs")
//    public void addDocs() {
//        subjectEsService.addDocs();
//    }
//    @GetMapping("/find")
//    public void find() {
//        subjectEsService.find();
//    }
//    @GetMapping("/search")
//    public void search() {
//        subjectEsService.search();
//    }
}
